package SpringBoot.spring_boot_starter_freemarker.D01_HelloWorld.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.titan.core.utils.data.FormatUtils;

/**
 *
 *
 * @author 周成功
 *
 */
@RestController
@RequestMapping(value = "/D01")
public class D01Controller {
    @RequestMapping(value = "/hello1")
    public ModelAndView hello1(ModelAndView modelAndView) {
        modelAndView.setViewName("index");
        
        List<String> userList=new ArrayList<String>();
        userList.add("admin");
        userList.add("user1");
        userList.add("user2");
        
        modelAndView.addObject("userList", userList);
        modelAndView.addObject("strVar", "zzz, " + FormatUtils.getSysdate("yyyy-MM-dd HH:mm:ss"));
        return modelAndView;
    }    

    @RequestMapping(value = "/hello2")
    public ModelAndView hello2(HttpServletRequest request, HttpServletResponse response) throws Exception {
        List<String> userList=new ArrayList<String>();
        userList.add("admin");
        userList.add("user1");
        userList.add("user2");
        request.setAttribute("userList", userList);
        request.setAttribute("strVar", "zzz, " + FormatUtils.getSysdate("yyyy-MM-dd HH:mm:ss"));
        return new ModelAndView("index");
    }    

}
